library(here)
## here() starts at /home/natasa/Desktop/master_project/Master-Project-Natasa-Mortvanski
library(phyloseq)
library(qiime2R)
library(microbiome)
## Loading required package: ggplot2
## 
## microbiome R package (microbiome.github.com)
##     
## 
## 
##  Copyright (C) 2011-2021 Leo Lahti, 
##     Sudarshan Shetty et al. <microbiome.github.io>
## 
## Attaching package: 'microbiome'
## The following object is masked from 'package:ggplot2':
## 
##     alpha
## The following object is masked from 'package:base':
## 
##     transform
library(microbiomeutilities)
## Loading required package: dplyr
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
## Warning: replacing previous import 'ggplot2::alpha' by 'microbiome::alpha' when
## loading 'microbiomeutilities'
library(tidyr)
library(data.table)
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
library(corrplot)
## corrplot 0.92 loaded
library(flextable)
library(writexl)

# Creating phyloseq object

physeq <- qza_to_phyloseq(
  features= "~/Desktop/master_project/Data_Hospital_donors/R2960/SCFA_QIIME2_analysis/table-dada2.qza",
  tree= "~/Desktop/master_project/Data_Hospital_donors/R2960/SCFA_QIIME2_analysis/rooted-tree.qza",
  taxonomy= "~/Desktop/master_project/Data_Hospital_donors/R2960/SCFA_QIIME2_analysis/taxonomy.qza",
  metadata = "~/Desktop/master_project/Master-Project-Natasa-Mortvanski/01_tidy_data/SCFA_alpha_donors.tsv"
  )

Taxonomic level: Family

Creating a table of abundances on Family level:

# tax_glom function merges species that have the same taxonomy at a certain 
# taxonomic rank - in this case family level
glom <- tax_glom(physeq, taxrank=rank_names(physeq)[5])

# psmelt function melts phyloseq data object into large data.frame 
smelted_data <- psmelt(glom) 

abundances_fam <- smelted_data %>% select(-c(Kingdom, Phylum, Class, Order)) %>%
        spread(Family, Abundance) %>%
  group_by(Sample) %>%
  summarize(across(3:63, ~unique(na.omit(.x))),.groups = 'drop')

abundances_fam
## # A tibble: 104 × 62
##    Sample donor_donation acetic_acid propionic_acid butyric_acid shannon_entropy
##    <chr>  <chr>                <dbl>          <dbl>        <dbl>           <dbl>
##  1 A1-Pl… CGR32F_7th           336.            77.3         75.8            6.81
##  2 A10-P… CLA33F_11th          177.            60.3        163.             6.63
##  3 A11-P… MBD34F_3rd            43.7           22.8         24.1            7.18
##  4 A12-P… FBG21M_4th           187.            46.0         42.6            6.69
##  5 A2-Pl… RTF49M_4th            52.3           14.2         16.1            6.86
##  6 A3-Pl… SMP48F_6th            47.0           18.6         17.6            6.65
##  7 A3-Pl… RTF49M_10th          369.           131.          87.1            6.42
##  8 A4-Pl… RTF49M_15th          131.            36.4         82.1            6.52
##  9 A5-Pl… EDR39F_1st           126.            67.1         57.8            6.36
## 10 A6-Pl… ATH27F_1st            67.0           32.3         25.3            6.82
## # ℹ 94 more rows
## # ℹ 56 more variables: chao1 <dbl>, fisher_alpha <dbl>, margalef <dbl>,
## #   gini_index <dbl>, menhinick <dbl>, strong <dbl>, simpson <dbl>,
## #   faith_pd <dbl>, pielou_evenness <dbl>, `[Barnesiellaceae]` <dbl>,
## #   `[Cerasicoccaceae]` <dbl>, `[Mogibacteriaceae]` <dbl>,
## #   `[Odoribacteraceae]` <dbl>, `[Paraprevotellaceae]` <dbl>,
## #   `[Tissierellaceae]` <dbl>, Alcaligenaceae <dbl>, …
write.table(abundances_fam, file = here("01_tidy_data", "abundance_family.tsv"), row.names=FALSE, sep="\t", quote=FALSE)

First lets check correlations between alpha diversity metrics and family abundances:

# Save results as data frame
tax_alpha_cor <- as.data.frame(cor(abundances_fam[, c(6:15)], abundances_fam[,c(16:50)]))
tax_alpha_cor %>% tibble::rownames_to_column() %>% flextable()

rowname

[Barnesiellaceae]

[Cerasicoccaceae]

[Mogibacteriaceae]

[Odoribacteraceae]

[Paraprevotellaceae]

[Tissierellaceae]

Alcaligenaceae

Anaeroplasmataceae

Bacteroidaceae

Bifidobacteriaceae

Campylobacteraceae

Carnobacteriaceae

Christensenellaceae

Clostridiaceae

Coriobacteriaceae

Dehalobacteriaceae

Desulfovibrionaceae

Elusimicrobiaceae

Enterobacteriaceae

Enterococcaceae

Erysipelotrichaceae

Eubacteriaceae

Fusobacteriaceae

Gemellaceae

Lachnospiraceae

Lactobacillaceae

Leptotrichiaceae

Leuconostocaceae

Methanobacteriaceae

mitochondria

Moraxellaceae

Oxalobacteraceae

Pasteurellaceae

Peptococcaceae

Peptostreptococcaceae

shannon_entropy

0.1961739

0.04587657

0.42021153

0.35326132

-0.10191302

0.15721016

0.012886096

0.01560096

-0.10401313

0.11404702

-0.13617509

0.08882543

0.38080772

0.047159992

0.21751498

0.16634117

0.48943128

0.0001774658

-0.2906366

0.11363339

0.00382816

0.04727198

0.09246265

0.05074282

0.110241368

0.05627490

0.01477416

0.036780567

0.42413481

-0.108218796

0.036780567

0.3966001

0.035661043

0.22682347

-0.04046494583

chao1

0.3983393

0.06216873

0.44673458

0.57132712

-0.11927104

0.09062786

-0.015945179

-0.08900386

0.06078133

0.14902624

-0.05413649

0.06547280

0.44115957

0.047179832

0.25969848

0.21082246

0.54066280

0.0755030083

-0.3274936

0.12923304

-0.13100630

-0.01609057

0.03090747

0.01174541

0.010581630

0.14336458

-0.02351381

0.042111939

0.38925318

0.014068695

0.042111939

0.5081410

-0.003174261

0.29422608

-0.00224146078

fisher_alpha

0.3936996

0.07091003

0.44612542

0.57158136

-0.13397330

0.09686233

-0.019397709

-0.09423500

0.05442319

0.14663316

-0.05118035

0.06909077

0.45375083

0.046097431

0.26354678

0.21765952

0.55212263

0.0624132416

-0.3438112

0.13301278

-0.13194528

-0.01817683

0.03711979

0.01023980

0.009574233

0.14914291

-0.02197679

0.028522431

0.40319678

-0.005772743

0.028522431

0.5168397

-0.009185043

0.30244158

-0.00001874811

margalef

0.3973124

0.06998401

0.44809716

0.57010029

-0.13619450

0.09749610

-0.015737951

-0.09103355

0.05468808

0.15119899

-0.04968787

0.06813527

0.45133338

0.050852669

0.26443582

0.21862052

0.55128947

0.0643366351

-0.3459213

0.13466851

-0.13082091

-0.01606918

0.03958950

0.01256500

0.012095435

0.15189829

-0.01941388

0.030786743

0.39658681

-0.005341178

0.030786743

0.5137065

-0.010093940

0.29894245

-0.00058696851

gini_index

-0.2744844

-0.07061008

-0.43738143

-0.47112177

0.12565482

-0.15186035

-0.001674808

0.01691102

0.03200879

-0.11179463

0.09933723

-0.08644533

-0.40048430

-0.048434934

-0.23175553

-0.16334157

-0.50953966

0.0151382790

0.3085910

-0.10099551

0.02995650

-0.03869648

-0.06774699

-0.04648364

-0.109638267

-0.06992236

0.00722504

-0.026077484

-0.46017354

0.097291881

-0.026077484

-0.4275486

-0.021119345

-0.26707969

0.01824285052

menhinick

0.3973124

0.06998401

0.44809716

0.57010029

-0.13619450

0.09749610

-0.015737951

-0.09103355

0.05468808

0.15119899

-0.04968787

0.06813527

0.45133338

0.050852669

0.26443582

0.21862052

0.55128947

0.0643366351

-0.3459213

0.13466851

-0.13082091

-0.01606918

0.03958950

0.01256500

0.012095435

0.15189829

-0.01941388

0.030786743

0.39658681

-0.005341178

0.030786743

0.5137065

-0.010093940

0.29894245

-0.00058696851

strong

0.2838715

0.06257516

0.15721202

0.26712286

-0.01478512

-0.05060710

-0.049059400

-0.13562485

0.11517395

0.11523776

0.10206079

0.01395815

0.23867993

-0.017552577

0.14899240

0.19784778

0.24840376

0.2308996280

-0.1147883

0.11663887

-0.18732150

-0.14083349

-0.01563013

-0.08508918

-0.292377731

0.17218141

-0.01629158

0.019243860

-0.01445655

0.193130418

0.019243860

0.2829366

-0.053582330

0.16556683

0.03796192806

simpson

-0.1482763

-0.02576009

0.22892981

-0.09787139

0.02939851

0.14114608

0.018318426

0.10745850

-0.29376183

0.02676426

-0.24701477

0.08533862

0.21786878

-0.012874742

0.09241626

0.08488361

0.27291167

-0.0152780533

-0.1015751

0.07548602

0.12344614

0.06359883

0.11583283

0.04800740

0.103548997

-0.05713842

0.04775054

0.035672617

0.29645593

-0.125998887

0.035672617

0.1856331

0.094908668

0.05686916

-0.09389218815

faith_pd

0.2845479

0.11051965

0.40234176

0.37278714

0.02526113

0.11640291

-0.137494964

-0.12712645

-0.03442883

0.20266925

-0.02828822

0.04559428

0.44693338

0.008489347

0.35554525

0.15031176

0.47533031

0.1585353280

-0.1709059

0.15630988

-0.04031295

-0.03580521

0.03968340

-0.03134623

-0.234888894

0.08073983

-0.06119944

-0.054986273

0.35482468

0.528622964

-0.054986273

0.3597795

-0.136334961

0.31505715

-0.04653492509

pielou_evenness

-0.3778888

-0.04163143

-0.03466668

-0.36034803

0.06859167

0.11427413

0.024317169

0.16931815

-0.30487484

-0.09177427

-0.18934919

0.04902762

-0.07733878

-0.041278643

-0.07766181

-0.08720601

-0.07324653

-0.1315143919

0.0867717

-0.03802944

0.23102940

0.10166737

0.08480880

0.05452080

0.166035449

-0.18446494

0.04095021

-0.003949148

0.13015699

-0.200237211

-0.003949148

-0.1521718

0.085048126

-0.09477153

-0.07529454866

# Plot correlation 
matrix_tax_alpha <- cor(abundances_fam[, c(6:15)], abundances_fam[,c(16:50)] , method = "spearman")
corrplot(matrix_tax_alpha, method="circle", tl.col = "black", tl.srt = 90, col.lim = c(-1,1), insig = "blank")

Then lets check correlations between SCFA and family abundances:

library(dichromat)
library(RColorBrewer)
library(graphics)


# Save results as data frame
tax_SCFA_cor <- as.data.frame(cor(abundances_fam[, c(3:5)], abundances_fam[,c(16:50)]))
tax_SCFA_cor %>% tibble::rownames_to_column() %>% flextable()

rowname

[Barnesiellaceae]

[Cerasicoccaceae]

[Mogibacteriaceae]

[Odoribacteraceae]

[Paraprevotellaceae]

[Tissierellaceae]

Alcaligenaceae

Anaeroplasmataceae

Bacteroidaceae

Bifidobacteriaceae

Campylobacteraceae

Carnobacteriaceae

Christensenellaceae

Clostridiaceae

Coriobacteriaceae

Dehalobacteriaceae

Desulfovibrionaceae

Elusimicrobiaceae

Enterobacteriaceae

Enterococcaceae

Erysipelotrichaceae

Eubacteriaceae

Fusobacteriaceae

Gemellaceae

Lachnospiraceae

Lactobacillaceae

Leptotrichiaceae

Leuconostocaceae

Methanobacteriaceae

mitochondria

Moraxellaceae

Oxalobacteraceae

Pasteurellaceae

Peptococcaceae

Peptostreptococcaceae

acetic_acid

0.20524171

-0.09267731

-0.06139248

0.17632447

0.0408958294

-0.12083575

0.04613958

0.00224551

0.11191166

-0.01613749

-0.02146923

0.03069292

-0.1651295

0.095361137

-0.08406569

-0.1566521

-0.09321140013

0.20371895

0.1212529

-0.09577773

-0.008895018

-0.05338218

-0.1516329

0.04195436

0.1878028

0.02743697

-0.06169235

0.009990479

-0.11222351

0.03916014

0.009990479

-0.2014101

0.2155984

-0.11479548

-0.02437538

propionic_acid

0.05204696

-0.11126960

0.02929166

-0.02678931

0.0952342132

-0.09459811

-0.03003317

-0.03991217

-0.10476762

-0.04559440

0.01004809

0.03538336

-0.1134535

0.029136059

-0.07622693

-0.1017626

-0.00001110557

0.22930148

0.2051389

-0.08114750

0.053369255

-0.06856381

-0.1345117

0.01518367

0.0229006

0.09200223

-0.07703053

-0.010252414

-0.09729968

0.06968642

-0.010252414

-0.1431086

0.2591636

-0.08610552

-0.09916577

butyric_acid

-0.13604957

-0.10526382

-0.16101055

-0.17232419

-0.0004175809

-0.09642060

-0.01072453

-0.04490758

-0.07197388

-0.04747222

-0.02421638

0.16074285

-0.2196374

0.008502025

-0.12456361

-0.1438063

-0.15658623990

0.05946432

0.2165128

-0.10942620

0.112840386

-0.08831867

-0.1247286

0.06561711

0.1654345

-0.03863936

-0.02175125

0.018979201

-0.16384997

-0.04482030

0.018979201

-0.2561053

0.3480001

-0.16527575

-0.07693781

scalebluered <- colorRampPalette(brewer.pal(8, "RdBu"))(50)

# Plot correlation 
matrix_tax_SCFA <- cor(abundances_fam[, c(3:5)], abundances_fam[,c(16:50)] , method = "spearman")

#corrplot(matrix_tax_SCFA, method="circle", tl.col = "black", tl.srt = 90, col.lim = c(-1,1), is.corr = FALSE) 

# I did not like how the generic legend looked like, so I decided to generate legend separately. However,
# I did not know how to put it on right side of the plot to look like the other plots, so I put it on the left side...

corrplot(matrix_tax_SCFA, method="circle", tl.col = "black", tl.srt = 90, cl.pos="n", insig = "blank") 
colorlegend(xlim=c(-3,0), ylim=c(10,5), scalebluered, c(seq(-1,1,1)), align="r", vertical=TRUE, addlabels=TRUE)

Finally, lets check correlations between alpha diversity metrics and SCFA:

# Save results as data frame
alpha_SCFA_cor <- as.data.frame(cor(abundances_fam[, c(3:5)], abundances_fam[,c(6:15)]))
alpha_SCFA_cor %>% tibble::rownames_to_column() %>% flextable()

rowname

shannon_entropy

chao1

fisher_alpha

margalef

gini_index

menhinick

strong

simpson

faith_pd

pielou_evenness

acetic_acid

-0.2646461

-0.1095884

-0.1199726

-0.1176453

0.2153806

-0.1176453

0.13095051

-0.3855660

-0.01865583

-0.303903050

propionic_acid

-0.2595886

-0.1444708

-0.1557334

-0.1534482

0.2497485

-0.1534482

0.17265440

-0.2722972

-0.01298810

-0.229056041

butyric_acid

-0.3157031

-0.3299432

-0.3334144

-0.3327643

0.3318925

-0.3327643

-0.08957821

-0.1894455

-0.27550113

0.004129023

# Plot correlation 
matrix_alpha_SCFA <- cor(abundances_fam[, c(3:5)], abundances_fam[,c(6:15)] , method = "spearman")
corrplot(matrix_alpha_SCFA, method="circle", tl.col = "black", tl.srt = 90, col.lim = c(-1,1), insig = "blank")

Correlation plot for family abundancies vs. SCFA and alpha diversity all together:

matrix_all <- cor(abundances_fam[, c(3:15)], abundances_fam[,c(16:50)] , method = "spearman")
corrplot(matrix_all, method="circle", tl.col = "black", tl.srt = 90, col.lim = c(-1,1), insig = "blank")

Taxonomic level: Genus

Creating a table of abundances on Genus level:

# tax_glom function merges species that have the same taxonomy at a certain 
# taxonomic rank - in this case genus level
glom <- tax_glom(physeq, taxrank=rank_names(physeq)[6])

# psmelt function melts phyloseq data object into large data.frame 
smelted_data <- psmelt(glom) 

# Problem with Clostridium!
abundances_gen <- smelted_data %>% select(-c(Kingdom, Phylum, Class, Order, Family)) %>%
        spread(Genus, Abundance) %>%
  group_by(Sample) %>% select(-c(Clostridium)) %>%
  summarize(across(2:94, ~unique(na.omit(.x))),.groups = 'drop')

abundances_gen
## # A tibble: 104 × 94
##    Sample            peti donor_donation acetic_acid propionic_acid butyric_acid
##    <chr>            <int> <chr>                <dbl>          <dbl>        <dbl>
##  1 A1-Placa-E2  216133466 CGR32F_7th           336.            77.3         75.8
##  2 A10-Placa-E2 226170254 CLA33F_11th          177.            60.3        163. 
##  3 A11-Placa-E2 226175993 MBD34F_3rd            43.7           22.8         24.1
##  4 A12-Placa-E2 226180072 FBG21M_4th           187.            46.0         42.6
##  5 A2-Placa-E2  216133396 RTF49M_4th            52.3           14.2         16.1
##  6 A3-Placa-E1  226185617 SMP48F_6th            47.0           18.6         17.6
##  7 A3-Placa-E2  216136699 RTF49M_10th          369.           131.          87.1
##  8 A4-Placa-E2  216139548 RTF49M_15th          131.            36.4         82.1
##  9 A5-Placa-E2  216142212 EDR39F_1st           126.            67.1         57.8
## 10 A6-Placa-E2  216144512 ATH27F_1st            67.0           32.3         25.3
## # ℹ 94 more rows
## # ℹ 88 more variables: shannon_entropy <dbl>, chao1 <dbl>, fisher_alpha <dbl>,
## #   margalef <dbl>, gini_index <dbl>, menhinick <dbl>, strong <dbl>,
## #   simpson <dbl>, faith_pd <dbl>, pielou_evenness <dbl>,
## #   `[Eubacterium]` <dbl>, `[Ruminococcus]` <dbl>, `1-68` <dbl>,
## #   Acidaminococcus <dbl>, Acinetobacter <dbl>, Adlercreutzia <dbl>,
## #   AF12 <dbl>, Akkermansia <dbl>, Alistipes <dbl>, Anaerostipes <dbl>, …
write.table(abundances_gen, file = here("01_tidy_data", "abundance_genera.tsv"), row.names=FALSE, sep="\t", quote=FALSE)

First lets check correlations between alpha diversity metrics and family abundances:

# Save results as data frame
tax_alpha_cor <- as.data.frame(cor(abundances_gen[, c(7:16)], abundances_gen[,c(17:94)]))
tax_alpha_cor %>% tibble::rownames_to_column() %>% flextable()

rowname

[Eubacterium]

[Ruminococcus]

1-68

Acidaminococcus

Acinetobacter

Adlercreutzia

AF12

Akkermansia

Alistipes

Anaerostipes

Anaerotruncus

Bacteroides

Barnesiella

Bifidobacterium

Bilophila

Blautia

Butyricicoccus

Butyricimonas

Campylobacter

Catenibacterium

cc_115

Citrobacter

Collinsella

Coprobacillus

Coprococcus

Dehalobacterium

Desulfovibrio

Dialister

Dorea

Enterobacter

Enterococcus

Epulopiscium

Faecalibacterium

Fusobacterium

Gemmiger

Gluconacetobacter

Granulicatella

Haemophilus

Hafnia

Holdemania

human

Klebsiella

Lachnobacterium

Lachnospira

Lactobacillus

Lactococcus

Megamonas

Megasphaera

Methanobrevibacter

Mitsuokella

Morganella

Odoribacter

Oscillospira

Oxalobacter

Parabacteroides

Paraprevotella

Peptococcus

Phascolarctobacterium

Porphyromonas

Prevotella

Pseudomonas

Pseudoramibacter_Eubacterium

rc4-4

RFN20

Rikenella

Roseburia

Ruminococcus

Serratia

Slackia

SMB53

Sneathia

Streptococcus

Sutterella

Synergistes

Turicibacter

Veillonella

WAL_1855D

Weissella

shannon_entropy

0.07159998

0.13938767

0.23103013

0.108286334

0.036780567

0.068457389

0.17354547

0.21747245

0.48221400

-0.01550384

0.23152449

-0.10402188

0.04431397

0.11404702

0.27230601

-0.07156724

0.06095575072

0.452660506

-0.13617509

-0.270733340

0.30015993

0.02763261

0.14846651

0.01307427

0.27728119

0.16634117

0.39709750

-0.075214784

0.11158385

0.06751459

0.11363339

0.057805254

-0.23290899

0.09246265

-0.05628918

0.03779447

0.08882543

0.035661043

0.09788973

-0.09241026

0.309043913

0.06408121

0.32438746

0.0002913416

0.05627490

-0.15010474

0.18472891

0.15326186

0.42413481

0.17225303

-0.03861396

0.18666254

0.4686748

0.3966001

0.18359537

-0.10191302

0.18119343

0.033820084

0.08170784

0.2165781

0.015380381

0.04727198

0.25905638

0.08918314

-0.14074391

-0.06853381

0.26377240

0.03423626

0.229274107

-0.08552451

0.01477416

-0.007667943

0.012886096

0.19638858

-0.052283432

-0.2861082

0.13175347

0.036780567

chao1

-0.03638702

0.10205368

0.21274291

0.152584970

0.042111939

-0.021874857

0.31611978

0.36348536

0.52420789

-0.16313867

0.13168898

0.06077046

0.06291673

0.14902624

0.30325114

-0.05674697

0.07743809648

0.698884646

-0.05413649

-0.272253842

0.33423134

-0.06743896

0.18521457

0.09730856

0.39460160

0.21082246

0.41982657

-0.088170642

0.04342752

0.01427595

0.12923304

0.091035791

-0.35887258

0.03090747

-0.02826961

-0.04645710

0.06547280

-0.003174261

0.03220064

-0.16174144

0.263675376

0.11035859

0.26796493

-0.0789801950

0.14336458

-0.09338715

0.14848375

0.18019220

0.38925318

0.20769049

-0.11731234

0.32352868

0.5775615

0.5081410

0.22001099

-0.11927104

0.15345588

0.018964675

0.02210724

0.3270622

-0.078345476

-0.01609057

0.32736930

0.04514859

-0.05404873

-0.13528621

0.34206429

-0.01356003

0.238517312

-0.02537611

-0.02351381

-0.022595562

-0.015945179

0.26277538

-0.053687155

-0.2089988

0.06692396

0.042111939

fisher_alpha

-0.04266201

0.10243623

0.22777165

0.142881861

0.028522431

-0.018170692

0.30695543

0.36372284

0.52843491

-0.17079839

0.13419861

0.05441420

0.04653088

0.14663316

0.30520335

-0.06533926

0.06058732764

0.705909829

-0.05118035

-0.284136402

0.34014791

-0.06547499

0.18610876

0.10918235

0.39736206

0.21765952

0.43297201

-0.104391958

0.04544028

0.01023980

0.13301278

0.073548985

-0.35961444

0.03711979

-0.03201998

-0.04366895

0.06909077

-0.009185043

0.03640441

-0.15871957

0.276935541

0.09784401

0.27146610

-0.0826432096

0.14914291

-0.09628639

0.15289732

0.18495988

0.40319678

0.20402245

-0.11322640

0.31929618

0.5838954

0.5168397

0.21710880

-0.13397330

0.15784148

0.027229629

0.02004396

0.3207720

-0.074451843

-0.01817683

0.32360956

0.03903789

-0.05125168

-0.13404434

0.34823021

-0.01303907

0.248360533

-0.02453051

-0.02197679

-0.029756605

-0.019397709

0.26766104

-0.070188588

-0.2262530

0.07148311

0.028522431

margalef

-0.04294028

0.10703291

0.22081353

0.147170247

0.030786743

-0.014988000

0.30635207

0.36329867

0.52660033

-0.16756017

0.13279219

0.05467900

0.04908215

0.15119899

0.31168381

-0.06455511

0.06160509981

0.703323138

-0.04968787

-0.285537297

0.33033472

-0.06380222

0.18849984

0.10661453

0.39602264

0.21862052

0.42764732

-0.098549087

0.04850559

0.01256500

0.13466851

0.075039558

-0.35843293

0.03958950

-0.02837994

-0.04210025

0.06813527

-0.010093940

0.03859606

-0.15337586

0.271504546

0.10022254

0.26794237

-0.0844359241

0.15189829

-0.09583334

0.15123247

0.18654035

0.39658681

0.20843923

-0.11498723

0.31896261

0.5851950

0.5137065

0.21497119

-0.13619450

0.15573587

0.026531909

0.02187530

0.3276695

-0.073015363

-0.01606918

0.31517779

0.04119917

-0.04990957

-0.12627784

0.34971356

-0.01086296

0.246135995

-0.02197471

-0.01941388

-0.026716509

-0.015737951

0.25725703

-0.067240540

-0.2252004

0.07290958

0.030786743

gini_index

-0.04878789

-0.14172151

-0.27101405

-0.124796782

-0.026077484

-0.039736261

-0.24861298

-0.25221615

-0.51722967

0.06726804

-0.23208294

0.03201768

-0.03675671

-0.11179463

-0.28727367

0.06540978

-0.08547496357

-0.554753489

0.09933723

0.286216292

-0.32914016

-0.01431225

-0.15083960

-0.05752248

-0.36608418

-0.16334157

-0.40605757

0.120295470

-0.10668560

-0.05076923

-0.10099551

-0.049507254

0.26796761

-0.06774699

0.06275676

-0.02455684

-0.08644533

-0.021119345

-0.08923833

0.10308008

-0.324204596

-0.04836574

-0.33604171

-0.0005443647

-0.06992236

0.14100810

-0.19708097

-0.12450000

-0.46017354

-0.14386411

0.05044059

-0.28083386

-0.5142416

-0.4275486

-0.23115889

0.12565482

-0.19431764

-0.024596955

-0.06700058

-0.1814911

0.002865844

-0.03869648

-0.28919881

-0.08152186

0.10261073

0.09975348

-0.33282357

-0.03122341

-0.239554579

0.08815003

0.00722504

0.012485752

-0.001674808

-0.26427198

0.063402678

0.2891960

-0.12184022

-0.026077484

menhinick

-0.04294028

0.10703291

0.22081353

0.147170247

0.030786743

-0.014988000

0.30635207

0.36329867

0.52660033

-0.16756017

0.13279219

0.05467900

0.04908215

0.15119899

0.31168381

-0.06455511

0.06160509981

0.703323138

-0.04968787

-0.285537297

0.33033472

-0.06380222

0.18849984

0.10661453

0.39602264

0.21862052

0.42764732

-0.098549087

0.04850559

0.01256500

0.13466851

0.075039558

-0.35843293

0.03958950

-0.02837994

-0.04210025

0.06813527

-0.010093940

0.03859606

-0.15337586

0.271504546

0.10022254

0.26794237

-0.0844359241

0.15189829

-0.09583334

0.15123247

0.18654035

0.39658681

0.20843923

-0.11498723

0.31896261

0.5851950

0.5137065

0.21497119

-0.13619450

0.15573587

0.026531909

0.02187530

0.3276695

-0.073015363

-0.01606918

0.31517779

0.04119917

-0.04990957

-0.12627784

0.34971356

-0.01086296

0.246135995

-0.02197471

-0.01941388

-0.026716509

-0.015737951

0.25725703

-0.067240540

-0.2252004

0.07290958

0.030786743

strong

-0.11188448

-0.08337943

-0.04996814

0.071174960

0.019243860

-0.096462430

0.11713086

0.30594809

0.12292211

-0.25971058

-0.21268317

0.11517161

0.04135788

0.11523776

0.11241541

-0.03837496

-0.04857870484

0.407033975

0.10206079

-0.001743082

0.06678907

-0.20773467

0.14316523

0.13947974

0.06207966

0.19784778

0.20260374

0.067816446

-0.15198084

-0.06290857

0.11663887

0.066683353

-0.31387998

-0.01563013

0.08471928

-0.15735407

0.01395815

-0.053582330

-0.09304711

-0.18367770

-0.004601054

0.16825930

-0.05350426

-0.2683619423

0.17218141

0.10346468

-0.04239236

0.20109981

-0.01445655

0.20442597

-0.20031183

0.09894205

0.2817832

0.2829366

-0.04764457

-0.01478512

-0.02263729

0.031020173

-0.04906963

0.4168351

-0.173196574

-0.14083349

0.09150597

-0.08175925

0.10619220

-0.11240150

0.08556134

-0.10744658

0.092844612

0.15272963

-0.01629158

-0.001553990

-0.049059400

-0.01111107

-0.009895018

0.1337865

-0.04518166

0.019243860

simpson

0.17206462

0.06577147

0.15170291

0.005033255

0.035672617

0.115782331

-0.08907821

0.01158831

0.26524339

0.14128105

0.22033065

-0.29376672

0.02580022

0.02676426

0.08618909

-0.06359497

-0.00004246016

-0.002365089

-0.24701477

-0.118277906

0.20002527

0.06446741

0.05925141

-0.12882887

-0.03998642

0.08488361

0.28448218

0.008442535

0.07707192

0.08907522

0.07548602

0.036444531

-0.05762422

0.11583283

-0.07036063

0.06613545

0.08533862

0.094908668

0.10397670

-0.07280287

0.258577001

0.04081203

0.26724234

0.0528378731

-0.05713842

-0.15884818

0.13461960

0.12737346

0.29645593

0.11718767

0.04140618

-0.13191872

0.1618745

0.1856331

0.03938481

0.02939851

0.13051522

0.050686613

0.09772102

0.1067618

0.063874585

0.06359883

0.15685844

0.09001612

-0.25339392

-0.01804240

-0.02631759

0.03298194

0.141150275

-0.10125470

0.04775054

-0.009406021

0.018318426

0.07519729

-0.020617179

-0.2214215

0.12461393

0.035672617

faith_pd

0.11948764

0.03200218

0.13900974

0.287049979

-0.054986273

-0.005281073

0.32182268

0.37658481

0.23631863

-0.33942636

0.06903994

-0.03442819

-0.02319745

0.20266925

0.22381638

-0.03717315

0.11658230895

0.542337613

-0.02828822

-0.091551030

0.23064248

-0.12478391

0.27069566

0.06733520

0.27548528

0.15031176

0.41544342

-0.092222016

0.04536866

-0.03616911

0.15630988

0.003829546

-0.45481567

0.03968340

-0.02106906

-0.09688830

0.04559428

-0.136334961

0.01215433

-0.27508335

0.305044126

0.17997298

0.15965525

-0.2860212562

0.08073983

-0.08821139

0.14449164

0.13522310

0.35482468

0.03901185

-0.08556328

0.15483481

0.2881591

0.3597795

0.07753525

0.02526113

0.14154497

-0.004425807

0.06395975

0.1933990

-0.128385848

-0.03580521

0.19379312

0.05027771

-0.03145027

-0.25646404

0.24383624

0.02773202

0.224224377

-0.01229593

-0.06119944

-0.022356535

-0.137494964

0.12863566

-0.116453816

-0.1157593

0.10119138

-0.054986273

pielou_evenness

0.21042975

0.03011787

0.08322478

-0.095873353

-0.003949148

0.132002879

-0.21863064

-0.24030542

-0.02679162

0.24755163

0.20908765

-0.30487445

-0.02237424

-0.09177427

-0.10673545

-0.02812479

-0.01307993607

-0.396300680

-0.18934919

0.010096994

0.03938567

0.15696295

-0.08077847

-0.15894402

-0.18496708

-0.08720601

0.01403213

-0.013154554

0.10293579

0.08648484

-0.03802944

-0.035991315

0.19715646

0.08480880

-0.09139849

0.13624348

0.04902762

0.085048126

0.09819751

0.05689466

0.129180976

-0.07826021

0.15076665

0.1700677747

-0.18446494

-0.12177272

0.08683748

-0.05591838

0.13015699

-0.08073323

0.15665210

-0.23306289

-0.1891298

-0.1521718

-0.03081689

0.06859167

0.07559217

0.016824346

0.09874500

-0.2303185

0.150463629

0.10166737

-0.01771059

0.07734198

-0.19641210

0.04219254

-0.15136302

0.06647489

0.003835268

-0.14854419

0.04095021

0.002504481

0.024317169

-0.02002618

-0.008113092

-0.1549767

0.10538298

-0.003949148

# Plot correlation 
matrix_tax_alpha_1 <- cor(abundances_gen[, c(7:16)], abundances_gen[,c(17:55)] , method = "spearman")
corrplot(matrix_tax_alpha_1, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

matrix_tax_alpha_2 <- cor(abundances_gen[, c(7:16)], abundances_gen[,c(56:94)] , method = "spearman")
corrplot(matrix_tax_alpha_2, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

Then lets check correlations between SCFA and family abundances:

# Save results as data frame
tax_SCFA_cor <- as.data.frame(cor(abundances_gen[, c(4:6)], abundances_gen[,c(17:94)]))
tax_SCFA_cor %>% tibble::rownames_to_column() %>% flextable()

rowname

[Eubacterium]

[Ruminococcus]

1-68

Acidaminococcus

Acinetobacter

Adlercreutzia

AF12

Akkermansia

Alistipes

Anaerostipes

Anaerotruncus

Bacteroides

Barnesiella

Bifidobacterium

Bilophila

Blautia

Butyricicoccus

Butyricimonas

Campylobacter

Catenibacterium

cc_115

Citrobacter

Collinsella

Coprobacillus

Coprococcus

Dehalobacterium

Desulfovibrio

Dialister

Dorea

Enterobacter

Enterococcus

Epulopiscium

Faecalibacterium

Fusobacterium

Gemmiger

Gluconacetobacter

Granulicatella

Haemophilus

Hafnia

Holdemania

human

Klebsiella

Lachnobacterium

Lachnospira

Lactobacillus

Lactococcus

Megamonas

Megasphaera

Methanobrevibacter

Mitsuokella

Morganella

Odoribacter

Oscillospira

Oxalobacter

Parabacteroides

Paraprevotella

Peptococcus

Phascolarctobacterium

Porphyromonas

Prevotella

Pseudomonas

Pseudoramibacter_Eubacterium

rc4-4

RFN20

Rikenella

Roseburia

Ruminococcus

Serratia

Slackia

SMB53

Sneathia

Streptococcus

Sutterella

Synergistes

Turicibacter

Veillonella

WAL_1855D

Weissella

acetic_acid

-0.048231715

0.1544897

-0.1102867

0.13862046

0.009990479

-0.02676645

0.16799779

0.13478994

-0.2750128

-0.07243646

-0.1364766

0.11191741

-0.008353112

-0.01613749

0.01269479

0.15646609

0.14005715

-0.01370241

-0.02146923

0.1388464

-0.1324437

0.0437654

-0.06968238

-0.06124696

0.1291944

-0.1566521

-0.10066299

0.2395926

0.01444078

0.08974546

-0.09577773

-0.02618438

0.15406588

-0.1516329

0.1813651

0.06470166

0.03069292

0.2155984

-0.04863183

-0.02589902

-0.2252298

0.18563814

-0.1757955

0.11992883

0.02743697

0.2371008

-0.11117575

-0.122929703

-0.11222351

-0.11731467

-0.06654224

0.24937286

-0.08860194

-0.2014101

0.001515321

0.0408958294

-0.10698489

-0.10590844

-0.09910456

0.03855663

0.05254562

-0.05338218

-0.09030307

-0.09721057

-0.01654294

0.2908791

0.166630062

-0.03145050

-0.002093324

0.1543014

-0.06169235

0.2088887

0.04613958

-0.02808312

0.02228463

0.1432133

-0.10890530

0.009990479

propionic_acid

-0.005735281

0.1266747

-0.1001720

-0.02788658

-0.010252414

-0.04976517

0.01861533

0.09966111

-0.1973662

-0.02520465

-0.1224400

-0.10476337

-0.006627257

-0.04559440

0.04907994

0.06281714

0.09146129

-0.12609920

0.01004809

0.2112414

-0.1467473

0.0460600

-0.05305150

-0.02237027

-0.1147851

-0.1017626

-0.01367881

0.3995076

0.01840001

0.10654161

-0.08114750

-0.00475195

0.08658573

-0.1345117

0.1680536

0.09640637

0.03538336

0.2591636

-0.03841114

-0.10965634

-0.1985604

0.20207626

-0.1937272

-0.01866294

0.09200223

0.2969093

-0.09717652

0.001720114

-0.09729968

0.01532995

-0.06424677

0.04566383

-0.08370994

-0.1431086

-0.139153838

0.0952342132

-0.09406458

-0.12919530

-0.06966460

0.23646185

0.07792443

-0.06856381

-0.13788048

-0.08440119

0.01392033

0.2594391

-0.008833628

-0.02459244

-0.008608915

0.1236279

-0.07703053

0.2725172

-0.03003317

-0.08722848

0.03776054

0.2193534

-0.08368842

-0.010252414

butyric_acid

-0.058493438

0.1239715

-0.1055359

-0.08559811

0.018979201

-0.02814483

-0.07869090

-0.03782660

-0.2344429

0.11569087

-0.1551789

-0.07196801

-0.096788329

-0.04747222

-0.05143746

0.04416191

0.10036190

-0.28548307

-0.02421638

0.1621426

-0.1473870

0.1204202

-0.09024779

-0.05457181

-0.1499684

-0.1438063

-0.13759479

0.3160254

0.04932059

0.04830233

-0.10942620

-0.05041052

0.34579200

-0.1247286

0.2825893

0.16983778

0.16074285

0.3480001

-0.06554484

0.01971079

-0.2149490

0.04000696

-0.1533753

0.11134722

-0.03863936

0.4003416

-0.10839353

-0.062927225

-0.16384997

-0.04191171

-0.06476452

-0.04890160

-0.22153577

-0.2561053

-0.104676715

-0.0004175809

-0.10395799

-0.06268824

-0.07022972

0.04870113

0.16002676

-0.08831867

-0.13235299

-0.09046454

-0.02115347

0.3575807

-0.003415168

-0.03250106

-0.074563052

0.1551168

-0.02175125

0.2833861

-0.01072453

-0.07077105

0.11348622

0.2325765

-0.08491102

0.018979201

# Plot correlation 
matrix_tax_SCFA_1 <- cor(abundances_gen[, c(4:6)], abundances_gen[,c(17:55)] , method = "spearman")
corrplot(matrix_tax_SCFA_1, method="circle", tl.col = "black", tl.srt = 90, cl.pos="n", insig = "blank")
colorlegend(xlim=c(-3,0), ylim=c(10,5), scalebluered, c(seq(-1,1,1)), align="r", vertical=TRUE, addlabels=TRUE)

matrix_tax_SCFA_2 <- cor(abundances_gen[, c(4:6)], abundances_gen[,c(56:94)] , method = "spearman")
corrplot(matrix_tax_SCFA_2, method="circle", tl.col = "black", tl.srt = 90, cl.pos="n", insig = "blank")
colorlegend(xlim=c(-3,0), ylim=c(10,5), scalebluered, c(seq(-1,1,1)), align="r", vertical=TRUE, addlabels=TRUE)

  • Column “human” (from taxonomy file): k__Bacteria; p__Bacteroidetes; c__Bacteroidia; o__Bacteroidales; f__Rikenellaceae; g__human; s__gut metagenome

Correlation plot for genus abundancies vs. SCFA and alpha diversity all together:

matrix_all_1 <- cor(abundances_gen[, c(4:16)], abundances_gen[,c(17:55)] , method = "spearman")
corrplot(matrix_all_1, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

matrix_all_2 <- cor(abundances_gen[, c(4:16)], abundances_gen[,c(56:94)] , method = "spearman")
corrplot(matrix_all_2, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

Correlation with p-value

Family level

abund_fam <- abundances_fam[,3:62]
abund_fam <- abund_fam[, -c(4:13)]

testRes_fam = cor.mtest(abund_fam, conf.level = 0.95)
matrix_fam <- cor(abund_fam, method = "spearman")

corrplot(matrix_fam, p.mat = testRes_fam$p, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

# table of p-values
P_val_fam <- as.data.frame(testRes_fam$p)
P_val_fam <- P_val_fam[-c(4:50), -c(1:3)]

P_val_fam <- tibble::rownames_to_column(P_val_fam, "SCFA")

# export table
write_xlsx(P_val_fam, here("03_plots_and_tables", "correlation_p_val_family.xlsx"))

Genus level

abund_gen_1 <- abundances_gen[,4:55]
abund_gen_1 <- abund_gen_1[, -c(4:13)]

testRes_gen_1 <- cor.mtest(abund_gen_1, conf.level = 0.95)
matrix_gen_1 <- cor(abund_gen_1, method = "spearman")


corrplot(matrix_gen_1, p.mat = testRes_gen_1$p, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

# table of p-values
P_val_gen_1 <- as.data.frame(testRes_gen_1$p)
P_val_gen_1 <- P_val_gen_1[-c(4:42), -c(1:3)]
abund_gen_2 <- abundances_gen[,4:94]
abund_gen_2 <- abund_gen_2[, -c(4:52)]

testRes_gen_2 <- cor.mtest(abund_gen_2, conf.level = 0.95)
matrix_gen_2 <- cor(abund_gen_2, method = "spearman")

#pdf("my_plot.pdf")
corrplot(matrix_gen_2, p.mat = testRes_gen_2$p, method="circle", tl.col = "black", tl.srt = 90, tl.cex =0.9, col.lim = c(-1,1), insig = "blank")

#dev.off()


# table of p-values
P_val_gen_2 <- as.data.frame(testRes_gen_2$p)
P_val_gen_2 <- P_val_gen_2[-c(4:42), -c(1:3)]

# merge tables 
p_val_gen_all <- cbind(P_val_gen_1, P_val_gen_2)
p_val_gen_all <- tibble::rownames_to_column(p_val_gen_all, "SCFA")

# export table
write_xlsx(p_val_gen_all, here("03_plots_and_tables", "correlation_p_val_genus.xlsx"))